﻿using Microsoft.Xna.Framework;
using TomShane.Neoforce.Controls;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace RebEngine.Managers
{
    public class InputManager : GameComponent
    {
        private static Manager neoforceManager;

        /// <summary>
        /// Neoforces Manager Instance.
        /// </summary>
        public static Manager Manager
        {
            private set { ;}
            get { return neoforceManager; }
        }

        public InputManager(Game game)
            : base(game)
        {
            neoforceManager = new TomShane.Neoforce.Controls.Manager(EngineManager.Game, EngineManager.GDManager, "Default");
            neoforceManager.SkinDirectory = "Content/Skins/";
        }

        /// <summary>
        /// Initialises the Manager to some default properies.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();
            
            neoforceManager.AutoCreateRenderTarget = true;
            neoforceManager.TargetFrames = 60;

            neoforceManager.Initialize();
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            neoforceManager.Update(gameTime);            
        }

        public static void Draw(GameTime gameTime)
        {
            //EngineManager.Device.Clear(Color.White);
            neoforceManager.BeginDraw(gameTime);
            neoforceManager.EndDraw(new Rectangle(0, 0, EngineManager.Width, EngineManager.Height));
        }
    }
}
